<?php 
class ActivityCommon
{
	var $db;
	function __construct()
	{
		global $db;	
		$this -> db     = & $db;
	}
	//添加活动
	function add_activity()
	{
		$sql="INSERT INTO ".ACTIVITY_COMMON." (`title` ,`desc` , `start_time` ,`end_time` ,`create_user` ,`status`,`displayorder`" .
				",`pic` ,`brand_ids`,`discount`,`tags`,`key_active`,`include_ids`,`exclude_ids`,`rule`,`rule_api`,`cat_ids`)" .
				"VALUES ( '$_POST[title]','$_POST[desc]','".strtotime($_POST['stime'])."','".strtotime($_POST['etime'])."','" .
				"".$_SESSION[ADMIN_USER]."','$_POST[status]','0','$_POST[pic]','$_POST[brandid]','$_POST[discount]'," .
				"'$_POST[tags]','$_POST[key_active]','$_POST[include_ids]','$_POST[exclude_ids]','$_POST[rule]','$_POST[rule_api]','$_POST[cat_ids]')";

		$this->db->query($sql);
	}

	//修改活动
	function edit_activity()
	{
		$sql="UPDATE ".ACTIVITY_COMMON."  SET `title` = '$_POST[title]',`desc` = '$_POST[desc]',`start_time` =  '".strtotime($_POST['stime'])."'," .
				"`end_time` = '".strtotime($_POST['etime'])."',`pic` = '$_POST[pic]',`status` = '$_POST[status]'," .
				"`brand_ids`='$_POST[brandid]',`discount`='$_POST[discount]' ,`tags`='$_POST[tags]',`key_active`='$_POST[key_active]'," .
				"`include_ids`='$_POST[include_ids]',`exclude_ids`='$_POST[exclude_ids]',`rule`='$_POST[rule]',`rule_api`='$_POST[rule_api]',`cat_ids`='$_POST[cat_ids]' " .
				"WHERE `id` ='$_POST[id]'  ";
		$this->db->query($sql);

//		$sql ="update ".ACTIVITYPRODUCT. " set `status`='$_POST[status]', `start_time` =  '".strtotime($_POST['stime'])."',`end_time` = '".strtotime($_POST['etime'])."' where activity_id= '$_POST[id]'";

//		$this->db->query($sql);

	}


}
?>